<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="theme-color" content="#2D2D2D" />
  
  <title>PySNN :: pysnn.file_io</title>
  

  <link rel="icon" type="image/png" sizes="32x32" href="_static/img/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="_static/img/favicon-16x16.png">
        <link rel="index" title="Index"
              href="genindex.html"/>

  <link rel="stylesheet" href="_static/css/insegel.css"/>

  <script type="text/javascript">
    var DOCUMENTATION_OPTIONS = {
        URL_ROOT:'',
        VERSION:'0.0.1',
        LANGUAGE:'None',
        COLLAPSE_INDEX:false,
        FILE_SUFFIX:'.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
    };
  </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>

  <script src="https://email.tl.fortawesome.com/c/eJxNjUEOgyAQAF8jR7Kw6wIHDh7sP1Cw2mgxgmn6-3JsMqc5zEQfE8dkxOY1KKMUOI3ACFKRJpSW2AAp7ontYIaxI6i7XPJVwyeVfCQ550Os3jLrGSNOLgbdAy6s0PBk2TFNjEbsfq31LB0OnX407pJa5v2faRadwSW63mn5KuLyR9j2tgx3zecanl-55R_-jjPs"></script>

</head>

<body>
  <div id="insegel-container">
    <header>
      <div id="logo-container">
          
          <a href="index.html"><img src="_static/img/logo.svg"></a>
          

      </div>
      <div id="project-container">
        <h1>PySNN Documentation</h1>
      </div>
    </header>

    <div id="content-container">

      <div id="main-content-container">
        <div id="main-content-header">
          <h1>pysnn.file_io</h1>
        </div>
        <div id="main-content">
          
  <div class="section" id="pysnn-file-io">
<h1>pysnn.file_io<a class="headerlink" href="#pysnn-file-io" title="Permalink to this headline">¶</a></h1>
<dl class="simple">
<dt>The following set of functions is adapted from the SLAYER repository, found at:</dt><dd><p><a class="reference external" href="https://github.com/bamsumit/slayerPytorch">https://github.com/bamsumit/slayerPytorch</a></p>
</dd>
</dl>
<span class="target" id="module-pysnn.file_io"></span><dl class="class">
<dt id="pysnn.file_io.Events">
<em class="property">class </em><code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">Events</code><span class="sig-paren">(</span><em class="sig-param">x_events</em>, <em class="sig-param">y_events</em>, <em class="sig-param">p_events</em>, <em class="sig-param">t_events</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.Events" title="Permalink to this definition">¶</a></dt>
<dd><p>This class provides a way to store, read, write and visualize spike Events.</p>
<dl class="simple">
<dt>Members:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">x</span></code> (numpy <code class="docutils literal notranslate"><span class="pre">int</span></code> array): <cite>x</cite> index of spike Events.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">y</span></code> (numpy <code class="docutils literal notranslate"><span class="pre">int</span></code> array): <cite>y</cite> index of spike Events (not used if the spatial dimension is 1).</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">p</span></code> (numpy <code class="docutils literal notranslate"><span class="pre">int</span></code> array): <cite>polarity</cite> or <cite>channel</cite> index of spike Events.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">t</span></code> (numpy <code class="docutils literal notranslate"><span class="pre">double</span></code> array): <cite>timestamp</cite> of spike Events. Time is assumend to be in ms.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">TD</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">Events</span><span class="p">(</span><span class="n">x_events</span><span class="p">,</span> <span class="n">y_events</span><span class="p">,</span> <span class="n">p_events</span><span class="p">,</span> <span class="n">t_events</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt id="pysnn.file_io.Events.to_spike_array">
<code class="sig-name descname">to_spike_array</code><span class="sig-paren">(</span><em class="sig-param">sampling_time=1</em>, <em class="sig-param">dim=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.Events.to_spike_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a numpy tensor that contains the spike Eventss sampled in bins of <cite>sampling_time</cite>.
The array is of dimension (channels, height, time) or``CHT`` for 1D data.
The array is of dimension (channels, height, width, time) or``CHWT`` for 2D data.</p>
<dl>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">sampling_time</span></code>: the width of time bin to use.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">dim</span></code>: the dimension of the desired tensor. Assignes dimension itself if not provided.</p></li>
</ul>
<p>y</p>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">spike</span> <span class="o">=</span> <span class="n">TD</span><span class="o">.</span><span class="n">to_spike_array</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pysnn.file_io.Events.to_spike_tensor">
<code class="sig-name descname">to_spike_tensor</code><span class="sig-paren">(</span><em class="sig-param">empty_tensor</em>, <em class="sig-param">sampling_time=1</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.Events.to_spike_tensor" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a numpy tensor that contains the spike Eventss sampled in bins of <cite>sampling_time</cite>.
The tensor is of dimension (channels, height, width, time) or``CHWT``.</p>
<dl class="simple">
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">empty_tensor</span></code> (<code class="docutils literal notranslate"><span class="pre">numpy</span> <span class="pre">or</span> <span class="pre">torch</span> <span class="pre">tensor</span></code>): an empty tensor to hold spike data</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sampling_time</span></code>: the width of time bin to use.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">spike</span> <span class="o">=</span> <span class="n">TD</span><span class="o">.</span><span class="n">to_spike_tensor</span><span class="p">(</span> <span class="n">torch</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">240</span><span class="p">,</span> <span class="mi">180</span><span class="p">,</span> <span class="mi">5000</span><span class="p">))</span> <span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.spike_array_to_events">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">spike_array_to_events</code><span class="sig-paren">(</span><em class="sig-param">spike_mat</em>, <em class="sig-param">sampling_time=1</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.spike_array_to_events" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns TD Events from a numpy array (of dimension 3 or 4).
The numpy array must be of dimension (channels, height, time) or``CHT`` for 1D data.
The numpy array must be of dimension (channels, height, width, time) or``CHWT`` for 2D data.</p>
<dl class="simple">
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">spike_mat</span></code>: numpy array with spike information.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sampling_time</span></code>: time width of each time bin.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">TD</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">spike_array_to_events</span><span class="p">(</span><span class="n">spike</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.read_1d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">read_1d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.read_1d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads one dimensional binary spike file and returns a TD Events.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 40 bit number.</p></li>
<li><p>First 16 bits (bits 39-24) represent the neuron_id.</p></li>
<li><p>Bit 23 represents the sign of spike Events: 0=&gt;OFF Events, 1=&gt;ON Events.</p></li>
<li><p>the last 23 bits (bits 22-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">TD</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">read_1d_spikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.encode_1d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">encode_1d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">TD</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.encode_1d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes one dimensional binary spike file from a TD Events.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 40 bit number.</p></li>
<li><p>First 16 bits (bits 39-24) represent the neuron_id.</p></li>
<li><p>Bit 23 represents the sign of spike Events: 0=&gt;OFF Events, 1=&gt;ON Events.</p></li>
<li><p>the last 23 bits (bits 22-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">TD</span></code> (an <code class="docutils literal notranslate"><span class="pre">file_io.Events</span></code>): TD Events.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">file_io</span><span class="o">.</span><span class="n">write1Dspikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">TD</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.read_2d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">read_2d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.read_2d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads two dimensional binary spike file and returns a TD Events.
It is the same format used in neuromorphic datasets NMNIST &amp; NCALTECH101.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 40 bit number.</p></li>
<li><p>First 8 bits (bits 39-32) represent the xID of the neuron.</p></li>
<li><p>Next 8 bits (bits 31-24) represent the yID of the neuron.</p></li>
<li><p>Bit 23 represents the sign of spike Events: 0=&gt;OFF Events, 1=&gt;ON Events.</p></li>
<li><p>The last 23 bits (bits 22-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">TD</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">read_2d_spikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.encode_2d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">encode_2d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">TD</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.encode_2d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes two dimensional binary spike file from a TD Events.
It is the same format used in neuromorphic datasets NMNIST &amp; NCALTECH101.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 40 bit number.</p></li>
<li><p>First 8 bits (bits 39-32) represent the xID of the neuron.</p></li>
<li><p>Next 8 bits (bits 31-24) represent the yID of the neuron.</p></li>
<li><p>Bit 23 represents the sign of spike Events: 0=&gt;OFF Events, 1=&gt;ON Events.</p></li>
<li><p>The last 23 bits (bits 22-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">TD</span></code> (an <code class="docutils literal notranslate"><span class="pre">file_io.Events</span></code>): TD Events.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">file_io</span><span class="o">.</span><span class="n">write2Dspikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">TD</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.read_3d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">read_3d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.read_3d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads binary spike file for spike Events in height, width and channel dimension and returns a TD Events.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 56 bit number.</p></li>
<li><p>First 12 bits (bits 56-44) represent the xID of the neuron.</p></li>
<li><p>Next 12 bits (bits 43-32) represent the yID of the neuron.</p></li>
<li><p>Next 8 bits (bits 31-24) represents the channel ID of the neuron.</p></li>
<li><p>The last 24 bits (bits 23-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">TD</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">read_3d_spikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.encode_3d_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">encode_3d_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">TD</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.encode_3d_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes binary spike file for TD Events in height, width and channel dimension.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Each spike Events is represented by a 56 bit number.</p></li>
<li><p>First 12 bits (bits 56-44) represent the xID of the neuron.</p></li>
<li><p>Next 12 bits (bits 43-32) represent the yID of the neuron.</p></li>
<li><p>Next 8 bits (bits 31-24) represents the channel ID of the neuron.</p></li>
<li><p>The last 24 bits (bits 23-0) represent the spike Events timestamp in microseconds.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">TD</span></code> (an <code class="docutils literal notranslate"><span class="pre">file_io.Events</span></code>): TD Events.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">file_io</span><span class="o">.</span><span class="n">write3Dspikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">TD</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.read_1d_num_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">read_1d_num_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.read_1d_num_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads a tuple specifying neuron, start of spike region, end of spike region and number of spikes from binary spike file.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Number of spikes data is represented by an 80 bit number.</p></li>
<li><p>First 16 bits (bits 79-64) represent the neuron_id.</p></li>
<li><p>Next 24 bits (bits 63-40) represents the start time in microseconds.</p></li>
<li><p>Next 24 bits (bits 39-16) represents the end time in microseconds.</p></li>
<li><p>Last 16 bits (bits 15-0) represents the number of spikes.</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">n_id</span><span class="p">,</span> <span class="n">t_start</span><span class="p">,</span> <span class="n">t_end</span><span class="p">,</span> <span class="n">n_spikes</span> <span class="o">=</span> <span class="n">file_io</span><span class="o">.</span><span class="n">read_1d_num_spikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
<span class="go">``t_start`` and ``t_end`` are returned in milliseconds</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.encode_1d_num_spikes">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">encode_1d_num_spikes</code><span class="sig-paren">(</span><em class="sig-param">filename</em>, <em class="sig-param">n_id</em>, <em class="sig-param">t_start</em>, <em class="sig-param">t_end</em>, <em class="sig-param">n_spikes</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.encode_1d_num_spikes" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes binary spike file given a tuple specifying neuron, start of spike region, end of spike region and number of spikes.</p>
<dl class="simple">
<dt>The binary file is encoded as follows:</dt><dd><ul class="simple">
<li><p>Number of spikes data is represented by an 80 bit number</p></li>
<li><p>First 16 bits (bits 79-64) represent the neuron_id</p></li>
<li><p>Next 24 bits (bits 63-40) represents the start time in microseconds</p></li>
<li><p>Next 24 bits (bits 39-16) represents the end time in microseconds</p></li>
<li><p>Last 16 bits (bits 15-0) represents the number of spikes</p></li>
</ul>
</dd>
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> (<code class="docutils literal notranslate"><span class="pre">string</span></code>): path to the binary file</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">n_id</span></code> (<code class="docutils literal notranslate"><span class="pre">numpy</span> <span class="pre">array</span></code>): neuron ID</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">t_start</span></code> (<code class="docutils literal notranslate"><span class="pre">numpy</span> <span class="pre">array</span></code>): region start time (in milliseconds)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">t_end</span></code> (<code class="docutils literal notranslate"><span class="pre">numpy</span> <span class="pre">array</span></code>): region end time (in milliseconds)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">n_spikes</span></code> (<code class="docutils literal notranslate"><span class="pre">numpy</span> <span class="pre">array</span></code>): number of spikes in the region</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">file_io</span><span class="o">.</span><span class="n">encode_1d_num_spikes</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">n_id</span><span class="p">,</span> <span class="n">t_start</span><span class="p">,</span> <span class="n">t_end</span><span class="p">,</span> <span class="n">n_spikes</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="pysnn.file_io.show_td">
<code class="sig-prename descclassname">pysnn.file_io.</code><code class="sig-name descname">show_td</code><span class="sig-paren">(</span><em class="sig-param">TD</em>, <em class="sig-param">frame_rate=24</em>, <em class="sig-param">pre_compute_frames=True</em>, <em class="sig-param">repeat=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pysnn.file_io.show_td" title="Permalink to this definition">¶</a></dt>
<dd><p>Visualizes TD Events.</p>
<dl class="simple">
<dt>Arguments:</dt><dd><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">TD</span></code>: spike Events to visualize.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">frame_rate</span></code>: framerate of visualization.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pre_compute_frames</span></code>: flag to enable precomputation of frames for faster visualization. Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">repeat</span></code>: flag to enable repeat of animation. Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p></li>
</ul>
</dd>
</dl>
<p>Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">show_td</span><span class="p">(</span><span class="n">TD</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>


        </div>
      </div>

      <div id="side-menu-container">

        <div id="search" role="search">
        <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
            <input type="text" name="q" placeholder="Search..." />
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
        </form>
</div>

        <div id="side-menu" role="navigation">

          
  
    
  
  
    <p class="caption"><span class="caption-text">Usage:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="neurons.html">Neurons</a></li>
<li class="toctree-l1"><a class="reference internal" href="connections.html">Connections</a></li>
<li class="toctree-l1"><a class="reference internal" href="learning_rules.html">Learning Rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="networks.html">Networks</a></li>
</ul>
<p class="caption"><span class="caption-text">Package Reference:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="connection_reference.html">pysnn.connection</a></li>
<li class="toctree-l1"><a class="reference internal" href="neuron_reference.html">pysnn.neuron</a></li>
<li class="toctree-l1"><a class="reference internal" href="network_reference.html">pysnn.network</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">pysnn.file_io</a></li>
<li class="toctree-l1"><a class="reference internal" href="functional_reference.html">pysnn.functional</a></li>
<li class="toctree-l1"><a class="reference internal" href="encoding_reference.html">pysnn.encoding</a></li>
<li class="toctree-l1"><a class="reference internal" href="datasets_reference.html">pysnn.datasets</a></li>
<li class="toctree-l1"><a class="reference internal" href="learning_reference.html">pysnn.learning</a></li>
<li class="toctree-l1"><a class="reference internal" href="utils_reference.html">pysnn.utils</a></li>
</ul>

  


        </div>

        

      </div>

    </div>

<footer>
    <div id="footer-info">
        <ul id="build-details">
            
                <li class="footer-element">
                    
                        <a href="_sources/file_io_reference.rst.txt" rel="nofollow"> source</a>
                    
                </li>
            

            

            
        </ul>
        <div id="credit">
            created with <a href="http://sphinx-doc.org/">Sphinx</a> and <a href="https://github.com/Autophagy/insegel">Insegel</a>

        </div>
    </div>

    <a id="menu-toggle" class="fa fa-bars" aria-hidden="true"></a>

    <script type="text/javascript">
      $("#menu-toggle").click(function() {
        $("#menu-toggle").toggleClass("toggled");
        $("#side-menu-container").slideToggle(300);
      });
    </script>

</footer> 

</div>

</body>
</html>